<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/fragments/head">
<title>用户编辑</title>
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">

		<div th:replace="admin/fragments/header"></div>
		<div th:replace="admin/fragments/mainsidebar::mainside('用户管理','user')"></div>

		<div class="content-wrapper">
			<section class="content-header">
				<h1>
					用户编辑
				</h1>
			</section>

			<section class="content">
				<div class="row">
					<div class="col-md-10">
						<div class="box  box-primary">
							<form class="form-horizontal form-edit" method="post">
								<div class="box-body">
									<input type="hidden" id="id" name="id" th:value="${user==null?'':user.id}"/>
									<div class="form-group">
										<label class="col-sm-2 control-label">用户名：</label>
										<div class="col-sm-10">
											<input id="userName" name="userName"
												th:value="${user==null?'':user.userName}"
												class="form-control" type="text" />
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">密码：</label>
										<div class="col-sm-10">
											<input id="userPwd" name="userPwd"
												th:value="${user==null?'':user.userPwd}"
												class="form-control" type="text" />
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">性别：</label>
										<div class="col-sm-10">
											<input id="sex" name="sex"
												th:value="${user==null?'':user.sex}" class="form-control"
												type="text" />
										</div>
									</div>
								</div>
								<div class="box-footer">
									<a type="button" class="btn btn-default btn-back"
										href="/admin/user/">返回</a>
									<button type="button"
										class="btn btn-info pull-right btn-submit">提交</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</section>
		</div>

		<div th:replace="admin/fragments/footer"></div>
	</div>

	<div th:replace="admin/fragments/script"></div>
	<script>
		$(".btn-submit").click(function() {
			$.ajax({
				type : "POST",
				url : "/admin/user/edit",
				data : $(".form-edit").serialize(),
				dataType : "JSON",
				success : function(res) {
					layer.msg(res.message, {
						time : 2000
					}, function() {
						location.href='/admin/user/';
					});
				}
			});
		});
	</script>
</body>
</html>